/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package web.control;

import data.dao.AdminFacade;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import data.vo.Admin;

/**
 *
 * @author User
 */
@ManagedBean
@RequestScoped
public class accesscontroler {
    @EJB
    private AdminFacade adminFc;
    
public String login;
public String key;

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String val() { 
        
        try {
            Admin admin = adminFc.find(this.login);
     if(admin.getLogin().equalsIgnoreCase(this.login) &&admin.getPasswd().equalsIgnoreCase(this.key)) {
         return "bienvenido.xhtml";
     } else {
         return "error.xhtml";
     }
     }
     catch(Exception ex)
         
     {
         return ex.getMessage();
     }
    }
    /**
     * Creates a new instance of accesscontroler
     */
    public accesscontroler() {
    }
}
